<?php

namespace App\Jobs\Train;

use App\Models\Train\TrainPoints\Repositories\Interfaces\TrainPointsRepositoryInterface;
use App\Trip\Train\TrainSchedule\TrainPassPoint;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

class ProcessAddTrainPoints implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    private TrainPassPoint $point;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct(TrainPassPoint $point)
    {
        $this->point = $point;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $repo = app(TrainPointsRepositoryInterface::class);
        $repo->addPoint($this->point->toArray());
    }
}
